<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>返回包含了所有时区标识符的数字索引数组</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="datetimezone.listabbreviations.html">« DateTimeZone::listAbbreviations</a></li>
      <li style="float: right;"><a href="class.dateinterval.html">DateInterval »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.datetimezone.html">DateTimeZone</a></li>
    <li>返回包含了所有时区标识符的数字索引数组</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="datetimezone.listidentifiers" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">DateTimeZone::listIdentifiers</h1>
  <h1 class="refname">timezone_identifiers_list</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.2.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">DateTimeZone::listIdentifiers</span> -- <span class="refname">timezone_identifiers_list</span> &mdash; <span class="dc-title">返回包含了所有时区标识符的数字索引数组</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-datetimezone.listidentifiers-description">
  <h3 class="title">说明</h3>
  <p class="para">面向对象风格</p>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><strong>DateTimeZone::listIdentifiers</strong></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$timezoneGroup</code><span class="initializer"> = DateTimeZone::ALL</span></span>, <span class="methodparam"><span class="type">?</span><span class="type"><span class="type">string</span><span class="type"></span></span> <code class="parameter">$countryCode</code><span class="initializer"> = <strong><code>null</code></strong></span></span>): <span class="type">array</span></div>

  <p class="para rdfs-comment">过程化风格</p>
  <div class="methodsynopsis dc-description"><span class="methodname"><a href="function.timezone-identifiers-list.html" class="methodname">timezone_identifiers_list</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$timezoneGroup</code><span class="initializer"> = DateTimeZone::ALL</span></span>, <span class="methodparam"><span class="type">?</span><span class="type"><span class="type">string</span><span class="type"></span></span> <code class="parameter">$countryCode</code><span class="initializer"> = <strong><code>null</code></strong></span></span>): <span class="type">array</span></div>

 </div>


 <div class="refsect1 parameters" id="refsect1-datetimezone.listidentifiers-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">timezoneGroup</code></dt>

     <dd>

      <p class="para">
       <span class="classname"><a href="class.datetimezone.html" class="classname">DateTimeZone</a></span> 类中的常量之一（或组合）。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">countryCode</code></dt>

     <dd>

      <p class="para">
       国家代码，兼容 ISO 3166-1 的两个大写字母。
      </p>
      <blockquote class="note"><p><strong class="note">注意</strong>: 
       <span class="simpara">
        只有当 <code class="parameter">timezoneGroup</code> 设置为
        <strong><code>DateTimeZone::PER_COUNTRY</code></strong> 时,该选项才会被使用。
       </span>
      </p></blockquote>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-datetimezone.listidentifiers-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回时区标识符的数组。只会返回没有过时的元素。要获取包含过时时区标识符的所有元素，使用
   <code class="literal">DateTimeZone::ALL_WITH_BC</code> 作为
   <code class="parameter">timezoneGroup</code> 的值。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-datetimezone.listidentifiers-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>8.0.0</td>
       <td>
        在此版本之前，失败时返回 <strong><code>false</code></strong>。
       </td>
      </tr>

      <tr>
       <td>7.1.0</td>
       <td>
        现在，<code class="parameter">countryCode</code> 可以为 null。
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-datetimezone.listidentifiers-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2048">
    <p><strong>示例 #1 <span class="methodname"><a href="function.timezone-identifiers-list.html" class="methodname">timezone_identifiers_list()</a></span> 范例</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$timezone_identifiers&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">DateTimeZone</span><span style="color: #007700">::</span><span style="color: #0000BB">listIdentifiers</span><span style="color: #007700">();<br />for&nbsp;(</span><span style="color: #0000BB">$i</span><span style="color: #007700">=</span><span style="color: #0000BB">0</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">&lt;&nbsp;</span><span style="color: #0000BB">5</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">++)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #0000BB">$timezone_identifiers</span><span style="color: #007700">[</span><span style="color: #0000BB">$i</span><span style="color: #007700">]</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
</pre></div>
    </div>
   </div>
  </p>

  <p class="para">
   <div class="example" id="example-2049">
    <p><strong>示例 #2 列出指定区域的标识符</strong></p>
    <div class="example-contents">
     <div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$timezone_identifiers&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">DateTimeZone</span><span style="color: #007700">::</span><span style="color: #0000BB">listIdentifiers</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">DateTimeZone</span><span style="color: #007700">::</span><span style="color: #0000BB">ASIA&nbsp;</span><span style="color: #007700">);<br />for&nbsp;(</span><span style="color: #0000BB">$i</span><span style="color: #007700">=</span><span style="color: #0000BB">0</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">&lt;&nbsp;</span><span style="color: #0000BB">5</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">++)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #0000BB">$timezone_identifiers</span><span style="color: #007700">[</span><span style="color: #0000BB">$i</span><span style="color: #007700">]</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
     <div class="cdata"><pre>
Asia/Aden
Asia/Almaty
Asia/Amman
Asia/Anadyr
Asia/Aqtau
</pre></div>
    </div>
   </div>
  </p>

  <p class="para">
   <div class="example" id="example-2050">
    <p><strong>示例 #3 列出多个区域的标识符</strong></p>
    <div class="example-contents">
     <div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$timezone_identifiers&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">DateTimeZone</span><span style="color: #007700">::</span><span style="color: #0000BB">listIdentifiers</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">DateTimeZone</span><span style="color: #007700">::</span><span style="color: #0000BB">ASIA&nbsp;</span><span style="color: #007700">|&nbsp;</span><span style="color: #0000BB">DateTimeZone</span><span style="color: #007700">::</span><span style="color: #0000BB">PACIFIC&nbsp;</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">join</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">',&nbsp;'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$timezone_identifiers&nbsp;</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
     <div class="cdata"><pre>
Asia/Aden, Asia/Almaty, Asia/Amman, Asia/Anadyr, Asia/Aqtau, Asia/Aqtobe,
Asia/Ashgabat, Asia/Atyrau, Asia/Baghdad, Asia/Bahrain, Asia/Baku,
Asia/Bangkok, Asia/Barnaul, Asia/Beirut, Asia/Bishkek, Asia/Brunei,
Asia/Chita, Asia/Choibalsan, Asia/Colombo, Asia/Damascus, Asia/Dhaka,
Asia/Dili, Asia/Dubai, Asia/Dushanbe, Asia/Famagusta, Asia/Gaza, Asia/Hebron,
Asia/Ho_Chi_Minh, Asia/Hong_Kong, Asia/Hovd, Asia/Irkutsk, Asia/Jakarta,
Asia/Jayapura, Asia/Jerusalem, Asia/Kabul, Asia/Kamchatka, Asia/Karachi,
Asia/Kathmandu, Asia/Khandyga, Asia/Kolkata, Asia/Krasnoyarsk,
Asia/Kuala_Lumpur, Asia/Kuching, Asia/Kuwait, Asia/Macau, Asia/Magadan,
Asia/Makassar, Asia/Manila, Asia/Muscat, Asia/Nicosia, Asia/Novokuznetsk,
Asia/Novosibirsk, Asia/Omsk, Asia/Oral, Asia/Phnom_Penh, Asia/Pontianak,
Asia/Pyongyang, Asia/Qatar, Asia/Qostanay, Asia/Qyzylorda, Asia/Riyadh,
Asia/Sakhalin, Asia/Samarkand, Asia/Seoul, Asia/Shanghai, Asia/Singapore,
Asia/Srednekolymsk, Asia/Taipei, Asia/Tashkent, Asia/Tbilisi, Asia/Tehran,
Asia/Thimphu, Asia/Tokyo, Asia/Tomsk, Asia/Ulaanbaatar, Asia/Urumqi,
Asia/Ust-Nera, Asia/Vientiane, Asia/Vladivostok, Asia/Yakutsk, Asia/Yangon,
Asia/Yekaterinburg, Asia/Yerevan, Pacific/Apia, Pacific/Auckland,
Pacific/Bougainville, Pacific/Chatham, Pacific/Chuuk, Pacific/Easter,
Pacific/Efate, Pacific/Fakaofo, Pacific/Fiji, Pacific/Funafuti,
Pacific/Galapagos, Pacific/Gambier, Pacific/Guadalcanal, Pacific/Guam,
Pacific/Honolulu, Pacific/Kanton, Pacific/Kiritimati, Pacific/Kosrae,
Pacific/Kwajalein, Pacific/Majuro, Pacific/Marquesas, Pacific/Midway,
Pacific/Nauru, Pacific/Niue, Pacific/Norfolk, Pacific/Noumea,
Pacific/Pago_Pago, Pacific/Palau, Pacific/Pitcairn, Pacific/Pohnpei,
Pacific/Port_Moresby, Pacific/Rarotonga, Pacific/Saipan, Pacific/Tahiti,
Pacific/Tarawa, Pacific/Tongatapu, Pacific/Wake, Pacific/Wallis
</pre></div>
    </div>
   </div>
  </p>

  <p class="para">
   <div class="example" id="example-2051">
    <p><strong>示例 #4 列出单个国家的标识符</strong></p>
    <div class="example-contents">
     <div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$timezone_identifiers&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">DateTimeZone</span><span style="color: #007700">::</span><span style="color: #0000BB">listIdentifiers</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">DateTimeZone</span><span style="color: #007700">::</span><span style="color: #0000BB">PER_COUNTRY</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"UA"&nbsp;</span><span style="color: #007700">);<br />foreach(&nbsp;</span><span style="color: #0000BB">$timezone_identifiers&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$identifier&nbsp;</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #0000BB">$identifier</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
     <div class="cdata"><pre>
Europe/Kyiv
Europe/Simferopol
Europe/Uzhgorod
Europe/Zaporozhye
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-datetimezone.listidentifiers-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.timezone-abbreviations-list.html" class="function" rel="rdfs-seeAlso">timezone_abbreviations_list()</a> - 别名 DateTimeZone::listAbbreviations</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>